﻿using CPPEI.Coolzon.Common;
using CPPEI.Coolzon.Core;
using CPPEI.Coolzon.Core.Repositories.SQL;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CPPEI.Coolzon.BrowserAppHost
{
    public partial class loadBrowserApp : System.Web.UI.Page
    {
        private static string strSolutionName;
        protected void Page_Load(object sender, EventArgs e)
        {
            //判断是否是登录用户
            if (!User.Identity.IsAuthenticated)
            {
                this.Response.Redirect("Login.aspx");
            }
            strSolutionName = Request.QueryString["solutionname"].ToString();
        }
        public string GetKeys()
        {
            //执行sql操作，查询出user
            Core.Data.User user;
            using (DbContext context = new DbContext())
            {
                SqlUserRepository userrepository = new SqlUserRepository();
                user = userrepository.GetUser(context, User.Identity.Name);
            }
            
            //加密配置信息
            string key = CryptoHelper.MD5Encrypt(string.Format("UserIdentity={0}&Password={1}&host={2}&solution={3}&Account={4}&", Guid.Empty, user.Password, ConfigurationManager.AppSettings["WebSiteHost"], strSolutionName, user.Account));
            return key;
        }
    }
}